Skip to content

test(worktree): check concurrent create names, not which create reached Git first - #35457

Merged
nwparker merged 2 commits into
mainfrom
nwparker/worktree-create-concurrency-test
Oct 28, 2026
Merged

nwparker merged 2 commits into
mainfrom
nwparker/worktree-create-concurrency-test

Conversation

@nwparker

@nwparker nwparker commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2
Prod 0 0 0 0

ELI5

A test starts two worktree creates with the same name at once. It checks that one gets the name and the other gets the next free one ("app" and "app-2"). It assumed the create that won the name would also be the first to reach Git. Each create first resolves its folder path on disk, and on a busy CI runner the other one can finish that first. The test then read the names in the wrong order and failed. It now checks which names were given out, not who got to Git first.

What Changed

Before: runtime-local-worktree-create.test.ts › "runtime concurrent creates on one name › gives the second create of app / nautilus its next candidate" failed at random with expected 'app-2' to be 'app' (or nautilus-2 / nautilus). Seen on #35414 (job 123139684188, shard 4/5) and #35385 (job 123152224174, shard 5/5).

After: the test asserts that exactly one of the two Git adds used the requested name, and that the other used the next candidate (app-2, or a tier-2 creature name for generated names). The rest is unchanged, including the check that the name is free again afterwards.

Mechanism:

  • Name claims are made in order: the first create to claim gets the base name.
  • After claiming, each create calls holdInFlightWorktreeCreate. That awaits a real fs.promises.realpath walk over the candidate path's ancestors (resolveCreatePathAlias) before it reaches the mocked addWorktree.
  • Those two filesystem calls finish in whatever order the thread pool returns them. So the app-2 create can call addWorktree first, which flips mock.calls[0].

Why

The product guarantees distinct names and that the base name goes to one create. It does not promise which create reaches Git first, so the test now asserts what is promised.

Reproduced deterministically: with a 50 ms delay injected before the base-name create's realpath, both cases fail with the exact CI assertion. With this change both pass under that delay. The delay was local only and is not committed.

Alternatives considered: mocking realpath would hide a real ordering, and tests should not depend on thread-pool timing.

Flag-off: test-only.

User-risk: none.

Linked Issue

CI flake triage (unit shards blocking merges).

Visual Proof

N/A. Test-only.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • The file passes 41/41 three runs in a row.

  • With the injected delay: 2 failed before the change, 41/41 after.

Checks run: pnpm tc, pnpm run typecheck:ci, pnpm run check:code-quality:changed, anti-slop oxlint, oxlint, ast-grep scan and gates.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

None.

Status

Ready for review.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@nwparker

Copy link
Copy Markdown
Contributor Author

STATUS: ready. Head 247ae36. Reproduced deterministically (a delayed base-name realpath gives the exact CI assertion); fixed by asserting names rather than add-call order. Checks: tc, typecheck:ci, code-quality, anti-slop, oxlint, ast-grep scan and gates; 41/41 passing x3. Review: e9-reviewer.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: bc79baff-6e38-4d64-9f2e-a2246cb602d1
Commits

Reviewing files that changed from the base of the PR and between b28bd42 and f7b06fd.

Files selected for processing: 1
  • src/main/runtime/runtime-local-worktree-create.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Walkthrough

The concurrent-create test no longer assumes that the create using the requested name reaches Git first. It checks that exactly one added path uses the requested name, then uses the other path for candidate-specific assertions.

Priority: Low

Merge Risk: Minimal · up to f7b06

The order-independent test change is narrowly scoped and presents no actionable merge-blocking risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Description check Warning The description explains the failure, the test change, the reason, alternatives, and reported validation. However, the required Linked Issue section contains only a generic description and no actual i… Add the actual linked issue under the Linked Issue section, for example by replacing Fixes # with the applicable issue number or URL. If the author is an internal maintainer and no issue is required, state that exception clearly.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the test change and the concurrency-order assumption it removes.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Full details: Description check

Explanation

The description explains the failure, the test change, the reason, alternatives, and reported validation. However, the required Linked Issue section contains only a generic description and no actual issue link or reference.

Resolution

Add the actual linked issue under the Linked Issue section, for example by replacing Fixes # with the applicable issue number or URL. If the author is an internal maintainer and no issue is required, state that exception clearly.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This test-only change appears safe to merge.

Summary

Removes a timing-dependent assertion from the concurrent worktree creation test.

  • Concurrent worktree tests check names instead of Git call order.

Reviews (1) · Last reviewed commit: "Merge branch 'main' into nwparker/worktr..." · Reviewed by Greptile

@nwparker
nwparker merged commit 4c31ba5 into main Oct 28, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant